namespace Webbness.Generator.CodeDom

import System
import System.Collections
import Neo.MetaModel
import System.Text

class ValidatingModel:
	
	[property(Model)]
	_model as Model
	
	[property(ResourcePath)]
	_resourcePath as string
	
	[property(UserClassTemplate)]
	_userClassTemplate as string
	
	[property(UserFileExtension)]
	_userFileExtension as string
	
	[property(SupportClassesTemplate)]
	_supportClassesTemplate as string
	
	[property(SupportFileExtension)]
	_supportFileExtension as string
	
	[property(Properties)]
	_properties as System.Collections.Specialized.StringDictionary
	
	[property(IsValid)]
	_isValid as bool
	
	[property(HasForcedOverwrite)]
	_hasForcedOverwrite as bool
	
	[property(Message)]
	_message as StringBuilder
	
	def constructor():
		_message = StringBuilder()
		_properties = System.Collections.Specialized.StringDictionary()
		
	def ToXml() as string:
		sb = StringBuilder()
		sb.AppendLine("""<?xml version="1.0"?>""")
		sb.AppendLine("""<!DOCTYPE database SYSTEM "norque.dtd">""")
		lst = List()
		if ResourcePath:
			lst.Add("resourcepath=\"${ResourcePath}\"")
		if UserClassTemplate:
			lst.Add("userclasstemplate=\"${UserClassTemplate}\"")
		if UserFileExtension:
			lst.Add("userfileextension=\"${UserFileExtension}\"")
		if SupportClassesTemplate:
			lst.Add("supportclassestemplate=\"${SupportClassesTemplate}\"")
		if SupportFileExtension:
			lst.Add("supportfileextension=\"${SupportFileExtension}\"")
		for de as DictionaryEntry in Properties:
			lst.Add("${de.Key.ToString().ToLower()}=\"${de.Value}\"")
		if lst.Count > 0:
			sb.Append("<?neo ").Append(join(lst, ' ')).AppendLine("?>")
		sb.Append(_model.ToXml())
		return sb.ToString()
